# -*- encoding: utf-8 -*-
# author:lmolhw
# datetime:2020-4-30 13:53

"""
文件说明：
    统计两个dict文件的包含关系
"""

def open_txt(file_name):
    with open(file_name, 'r') as f:
        try:
            line = f.readline()
            while line:
                yield line.strip()
                line = f.readline()
        except:
            print('No value')
# 大
path1 = './ID_train_line_dict.txt'
list1 = [x for x in open_txt(path1)]
# 小
path2 = './ID_valid_line_dict.txt'
list2 = [x for x in open_txt(path2)]

print('list1和list2的交集占list1的百分比：',len(set(list1) & set(list2)) / len(list1) *100)
print('list1占list1和list2的并集的百分比：',len(set(list1) | set(list2)) / len(list1) *100)
print('list1和list2的补集占list2的百分比：',len(set(list2) - set(list1)) / len(list2) *100)